var fs = require('fs');
var manager = require('sqlite3').verbose();

var file = 'test.sqlite';//这里写的就是数据库文件的路径
var connection = new manager.Database(file);

/**
 * 初始化表数据
 */
var initDataBase = function(){
    var sql = "INSERT INTO DBCTRL_REPO VALUES (?,?,'group',0)";
    var pstmt = connection.prepare(sql);
    for(var i=1;i<10;i++){
        pstmt.run([i, 'project'+i]);
    }
};

connection.all("SELECT * FROM DBCTRL_REPO",function(err,datas){
    console.log(JSON.stringify(datas));
});

connection.each("SELECT * FROM DBCTRL_REPO", function (err, row){
    if(row){

        //直接获取某个属性值
        //console.log(JSON.stringify(row.CODE));

        //遍历对象的所有属性和值
        for(var key in row){
            console.log(key+" = "+row[key]);
        }
    }
});

connection.close();
